﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using U3DSceneEditor;

public struct RhombusCell
{
    public Vector3 begin;

    public Vector3 end;

    public Color color;
}

public class RhombusUtil : MonoBehaviour
{
    //  长对角线长度
    public float rhombus_L = 0.64f;
    //  短对角线长度
    public float rhombus_H = 0.20f;

    //  区域长
    public float area_width = 50;
    //  区域宽
    public float area_height = 50;

    //  所有水平上的起始点
    public List<Vector3> points_hori = new List<Vector3>();

    //  所有竖直上的起始点
    public List<Vector3> points_vert = new List<Vector3>();

    public List<RhombusCell> allLines = new List<RhombusCell>();

    // Use this for initialization
    void Start ()
    {
        Vector3 dir_up = new Vector3(rhombus_L / 2, rhombus_H / 2, 0) - Vector3.zero;

        Vector3 dir_dn = new Vector3(rhombus_L / 2, 0, 0) - new Vector3(0, rhombus_H / 2, 0);

        Vector3 bein_vert = new Vector3(0, -area_height, 0);

        while (bein_vert.y < area_height)
        {
            {
                Vector3 end_up = bein_vert + dir_up.normalized * 100;
                RhombusCell rc = new RhombusCell();
                rc.begin = bein_vert;
                rc.end = end_up;
                rc.color = Color.white;
                allLines.Add(rc);

            }

            {
                Vector3 end_dn = bein_vert + dir_dn.normalized * 100;
                RhombusCell rc = new RhombusCell();
                rc.begin = bein_vert;
                rc.end = end_dn;
                rc.color = Color.yellow;
                allLines.Add(rc);

            }

            bein_vert.y += rhombus_H;
        }
    }


    void Update()
    {
        ShowGizmoz();
    }

    void ShowGizmoz()
    {
        for (int i = 0; i < allLines.Count; ++i)
        {
            RhombusCell rc = allLines[i];

            GLGizmos.DrawLine(rc.begin, rc.end, rc.color);
        }
    }
}
